<?php
namespace app\model;
use think\Model;

class TempCode extends Model
{
    // protected $table = 'user';
    // protected $autoWriteTimestamp = true;

    public function deleteCode($num){
        try {
            $data = $this->where('work_num',$num)->delete();
            return [true,$data];
            //code...
        } catch (\Exception $e) {
            return [false,$e->getMessage()];
            //throw $th;
        }
    //    return $this->where('work_num',$num)->find();
    }

    public function getInfoByWorkNum($num){
        try {
            $data = $this->where('work_num',$num)->find();
            return [true,$data];
            //code...
        } catch (\Exception $e) {
            return [false,$e->getMessage()];
            //throw $th;
        }
    //    return $this->where('work_num',$num)->find();
    }

    public function saveCode($work_num,$code){
        try {
            $this->insert(['work_num'=>$work_num,'code'=>$code]);
            return true;
            //code...
        } catch (\Exception $e) {
            return $e->getMessage();
            //throw $th;
        }
    //    return $this->where('work_num',$num)->find();
    }
    
}
